﻿using HamcoWcs.Entitys.Bases;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace HamcoWcs.Entitys.BaseConfigs
{
    public class GlobalConfig : BaseEntity, IEntityTypeConfiguration<GlobalConfig>
    {
        public string Name { get; set; }
        public int Offset { get; set; }
        public int Length { get; set; }
        public string Type { get; set; }
        public string PlcName { get; set; }
        public string PlcType { get; set; }
        public string Options { get; set; }

        public void Configure(EntityTypeBuilder<GlobalConfig> builder)
        {
            builder.HasComment("PLC全局配置表");
            builder.Property(x => x.Name).IsRequired().HasMaxLength(100).HasComment("配置名");
            builder.Property(x => x.PlcName).IsRequired().HasMaxLength(100).HasComment("PLC名");
            builder.Property(x => x.PlcName).IsRequired().HasMaxLength(100).HasComment("PLC类型");
            builder.Property(x => x.Offset).IsRequired().HasComment("偏移量");
            builder.Property(x => x.Length).IsRequired().HasDefaultValue(1).HasComment("长度");
            builder.Property(x => x.Type).IsRequired().HasMaxLength(100).HasComment("类型");
            builder.Property(x => x.Options).IsRequired(false).HasColumnType("text").HasComment("选项");
        }
    }
}
